package com.haiya.composite.shopping;

public class Goods implements Articles {
    private String name;
    private float unitPrice;
    private int quantity;

    /**
     *
     * @param name 名称
     * @param unitPrice 单价
     * @param quantity 数量
     */
    public Goods(String name, float unitPrice, int quantity) {
        this.name = name;
        this.unitPrice = unitPrice;
        this.quantity = quantity;
    }

    @Override
    public float calculation() {
        return unitPrice * quantity;
    }

    @Override
    public String toString() {
        return "Goods{" +
                "name='" + name + '\'' +
                ", unitPrice=" + unitPrice +
                ", quantity=" + quantity +
                ", total=" + calculation() +
                '}';
    }

    @Override
    public void show() {
        System.out.println("商品信息: " + toString());
    }
}
